package com.smooth.mall.exception;

public enum OrderStatusEnum {

    USER_CANCELED(0, "用户已取消"),
    NOT_PAY(1, "未付款"),
    GOODS_PAID(2,"商品已付款"),
    DELIVERED(3,"已发货"),
    DEAL_FINISHED(4,"交易完成");

    //异常编码
    private Integer code;
    //异常描述信息
    private String msg;

    OrderStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public static OrderStatusEnum codeOf(int code) {
        for (OrderStatusEnum orderStatusEnum:values() ) {
            if (orderStatusEnum.getCode() == code) {
                return orderStatusEnum;
            }
        }
        throw new SmoothMallException(SmoothMallExceptionEnum.NO_ENUM);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
